package com.wardrobe.soa.api.user;

import com.wardrobe.domain.user.UserInfo;
import com.wardrobe.mapper.master.user.UserMasterMapper;
import com.wardrobe.mapper.slave.user.UserSlaveMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by m1304 on 2018/8/6.
 */
@Service("userDao")
public class UserDao {

    @Resource
    private UserSlaveMapper userSlaveMapper;

    @Resource
    private UserMasterMapper userMasterMapper;

    public int insertUser(UserInfo info){
        return userMasterMapper.insertUser(info);
    }

    public int modifyUserPassword(UserInfo info){
        return userMasterMapper.updateUserPassword(info);
    }

    public Map<String,Object> getUser(String mobile, String password){
        return userSlaveMapper.getUserId(password,mobile);
    }

    public boolean queryUserForMobile(String mobileNumber){
        return userSlaveMapper.selectUserForMobile(mobileNumber).size()>0?true:false;
    }

    public Map<String,Object> getUserInfoById(long userId){
        return userSlaveMapper.selectUserByUserId(userId);
    }

    public List<Map<String,Object>> getUserByMobile(String mobileNumber){
        return  userSlaveMapper.selectUserForMobile(mobileNumber);
    }
}
